// 支付参数加密
// var obj = {
//     order_no : "123456789",
//     appid : "tst001",
//     key : "QIANMINGMIYAOCHUAN",
//     timestamp : "1426817510111",
//     amount :"100",
// }
// var arr = ["amount","appid","order_no","timestamp","key"];

// 按传递过来的参数排序（常用）
function paraEncryption (arr,obj) {
    if (arguments.length == 2 && arr && obj && typeof(obj) == "object" && arr instanceof Array) {
        var temp = "";
        var sign;
        for (var i = 0; i < arr.length; i++) {
            temp = temp + "|" + obj[arr[i]];
        }
        temp = temp + "|";
        sign = hex_md5 (temp);
        return sign;
    } 
}
// 按照首字母顺序排序
function paramInitialEncryption (obj) {
    if (obj && typeof (obj) == "object" && !(obj instanceof Array)) {
        var arr = [];
        var temp = "";
        var sign;
        for(var i in obj) {
            arr.push(i);
       }
    //    给数组按首字母顺序排序
       arr.sort();
       for (var i = 0; i < arr.length; i++) {
           temp = temp + "|" + obj[arr[i]];
       }
       temp = temp + "|";
       sign = hex_md5 (temp);
       return sign;
    } 
}

function searchOrderStatus(){
    var params = {
      "version" : "V2.0", //版本号(必填)
      "appid" : "305101700000261", //商户号(必填)
      "appSecret" : "6Y5Z86NS6GWo9fV8bVf5xjdRM9lwut51" //版本号(必填)
  };
  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "<%=sendCode%>/WDUnifiedPayWebFront/getWorkKey.do",
    "method": "POST",
    "headers": {
      "content-type": "application/json",
      "cache-control": "no-cache",
    },
    "data": JSON.stringify(params)
  }
  //order_no（refund_no）  订单号（如果是退款，则使用退款订单号）
  var singParmasArr=["amount","appid","order_no","timestamp","key"]; 

  $.ajax(settings).done(function (response) {
        var singParmasobj = {
          appid :"305101700000261",
          order_no:"13312",
          timestamp :Date.parse(new Date()),
          key :"30s65W8A82QN52d1J9XMD8Sy1sIK6172"
      }
     var sign =  paraEncryption(singParmasArr,singParmasobj);
     $.QuickRemote.AjaxJson(api+"/WDUnifiedPayWebFront/query/queryService.do", function (result) {
          alert("查询接口");
          
          
      },{
          "version" : "V2.0", //版本号(必填)
          "channel" : "wepay_appand ", //第三方支付渠道(必填)
          "submerno" : "", //子商户号(必填)
          "txnmode" : "1", //交易方式(必填)
          "appid" : "305101700000261", //商户号(必填)
          "order_no" : "", //订单号(必填)
          "refund_no" : "", //退款订单号（可选）
          "nonce" : "", //32 位字符和数字随机字符串(可选)
          "timestamp" : "", //服务端的时间(必填)
          "sign" : sign, //参数签名(必填)
          "queryType" : "", //查询类型(必填)
          "conditional_ data" : "", //条件参数(特定条件下必填)
          "bizType" : "", //产品类型(特定条件下必填)
      });
  });
}


